home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Reversed wipes ƒ / SlideWipe reversed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  3.2 KB  |  109 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        SlideWipe reversed.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define CorrectTime 1
  32. #define theWindowWidth (boundsRect.right-boundsRect.left)
  33. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  34.  
  35. pascal short SlideWipeReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  36.  
  37. /* Split the screen into 10 sections, then alternatively scroll left and right,
  38.    starting at the bottom section and working toward the top. */
  39.    
  40. pascal short SlideWipeReversed(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  41. {
  42.     int                x, y;
  43.     Rect            theRect, dest;
  44.     Rect            scrollsource;
  45.     int                direction;
  46.     int                BoxSize, StripSize;
  47.     
  48.     BoxSize=theWindowWidth/25;
  49.     StripSize=theWindowHeight/10;
  50.     
  51.     direction = 0;
  52.     for(y = theWindowHeight-StripSize; y >= 0; y -= StripSize)
  53.     {
  54.         scrollsource = boundsRect;
  55.         scrollsource.top+=y;
  56.         scrollsource.bottom = scrollsource.top + StripSize;
  57.         
  58.         dest = scrollsource;
  59.         
  60.         theRect.top = boundsRect.top + y;
  61.         theRect.bottom = theRect.top + StripSize;
  62.         
  63.         if(direction == 0)
  64.         {
  65.             dest.right = dest.left + BoxSize;
  66.             
  67.             theRect.left = boundsRect.right-BoxSize;
  68.             theRect.right = boundsRect.right;
  69.             
  70.             for(x = boundsRect.right - BoxSize; x >= boundsRect.left; x -= BoxSize)
  71.             {
  72.                 StartTiming();
  73.                 theRect.left = x;
  74.                 ScrollRect(&scrollsource, BoxSize, 0, 0L);
  75.                 CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  76.                         &theRect, &dest, 0, 0L);
  77.                 theRect.right = x;
  78.                 TimeCorrection(CorrectTime);
  79.             }
  80.             CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  81.                     &scrollsource, &scrollsource, 0, 0L);
  82.         }
  83.         else
  84.         {
  85.             dest.left = dest.right - BoxSize;
  86.             
  87.             theRect.left = boundsRect.left;
  88.             theRect.right = theRect.left + BoxSize;
  89.             
  90.             for(x = boundsRect.left+BoxSize; x <= boundsRect.right; x += BoxSize)
  91.             {
  92.                 StartTiming();
  93.                 theRect.right = x;
  94.                 ScrollRect(&scrollsource, -BoxSize, 0, 0L);
  95.                 CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  96.                         &theRect, &dest, 0, 0L);
  97.                 theRect.left = x;
  98.                 TimeCorrection(CorrectTime);
  99.             }
  100.             CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  101.                     &scrollsource, &scrollsource, 0, 0L);
  102.         }
  103.         
  104.         direction = 1 - direction;
  105.     }
  106.     
  107.     return 0;
  108. }
  109.